package com.ftg.shopping.orderdetails.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ftg.shopping.config.LayuiPage;
import com.ftg.shopping.orderdetails.entity.Orderdetails;
import com.ftg.shopping.orderdetails.mapper.OrderdetailsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderdetailsService {

    @Autowired
    OrderdetailsMapper orderdetailsMapper;

    public LayuiPage<Orderdetails> layuipage(int page, int limit, String dname) {
        IPage<Orderdetails> ip = new Page<>(page, limit);
        QueryWrapper qw = new QueryWrapper();
        qw.like("orderid", dname);
        orderdetailsMapper.selectPage(ip, dname == null || dname.equals("") ? null :  qw);
        return new LayuiPage<>(ip);

    }

    public int update(Orderdetails d) {
        return orderdetailsMapper.updateById(d);
    }

    public int del(int id){
        return orderdetailsMapper.deleteById(id);
    }
}
